﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Ttifa.Log;

namespace Ttifa.JobScheduler
{
    public class SimplyService
    {
        private static CancellationTokenSource mTokenSource = null;

        public void Start()
        {
            mTokenSource = new CancellationTokenSource();
            Task.Run(() => Excute());
        }

        public void Stop()
        {
            mTokenSource.Cancel();
        }

        private void Excute()
        {
            //每5秒执行一次
            while (!mTokenSource.IsCancellationRequested)
            {
                //ToDo
                LogFactory.GetLogger().Info(DateTime.Now.ToString());

                Thread.Sleep(5000);
            }

            mTokenSource.Dispose();
            mTokenSource = null;
        }
    }

}
